﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.JournalLog
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem
{
  public class JournalLog
  {
    [SaveableField(0)]
    public readonly CampaignTime LogTime;
    [SaveableField(1)]
    public readonly TextObject LogText;
    [SaveableField(2)]
    public readonly TextObject TaskName;
    [SaveableField(4)]
    public readonly int Range;
    [SaveableField(5)]
    public readonly LogType Type;

    internal static void AutoGeneratedStaticCollectObjectsJournalLog(
      object o,
      List<object> collectedObjects)
    {
      ((JournalLog) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected virtual void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      CampaignTime.AutoGeneratedStaticCollectObjectsCampaignTime((object) this.LogTime, collectedObjects);
      collectedObjects.Add((object) this.LogText);
      collectedObjects.Add((object) this.TaskName);
    }

    internal static object AutoGeneratedGetMemberValueCurrentProgress(object o)
    {
      return (object) ((JournalLog) o).CurrentProgress;
    }

    internal static object AutoGeneratedGetMemberValueLogTime(object o)
    {
      return (object) ((JournalLog) o).LogTime;
    }

    internal static object AutoGeneratedGetMemberValueLogText(object o)
    {
      return (object) ((JournalLog) o).LogText;
    }

    internal static object AutoGeneratedGetMemberValueTaskName(object o)
    {
      return (object) ((JournalLog) o).TaskName;
    }

    internal static object AutoGeneratedGetMemberValueRange(object o)
    {
      return (object) ((JournalLog) o).Range;
    }

    internal static object AutoGeneratedGetMemberValueType(object o)
    {
      return (object) ((JournalLog) o).Type;
    }

    [SaveableProperty(3)]
    public int CurrentProgress { get; private set; }

    public JournalLog(
      CampaignTime logTime,
      TextObject logText,
      TextObject taskName = null,
      int currentProgress = 0,
      int range = 0,
      LogType type = LogType.Text)
    {
      this.LogTime = logTime;
      this.LogText = logText;
      this.TaskName = taskName;
      this.CurrentProgress = currentProgress;
      this.Range = range;
      this.Type = type;
    }

    public void UpdateCurrentProgress(int progress) => this.CurrentProgress = progress;

    public bool HasBeenCompleted() => this.CurrentProgress >= this.Range;

    public TextObject GetTimeText()
    {
      CampaignTime campaignTime = CampaignTime.Now;
      int num1 = MathF.Ceiling(campaignTime.ToDays);
      campaignTime = this.LogTime;
      int num2 = MathF.Ceiling(campaignTime.ToDays);
      int variable = num1 - num2;
      TextObject text;
      switch (variable)
      {
        case 0:
          text = GameTexts.FindText("str_today");
          break;
        case 1:
          text = GameTexts.FindText("str_yesterday");
          break;
        default:
          text = GameTexts.FindText("str_DAY_days_ago");
          text.SetTextVariable("DAY", variable);
          break;
      }
      return text;
    }
  }
}
